-- hierophant
-- created by panyl
-- 教皇

return {
    apply = function(cardId)
        -- 随机获得一个卷轴
        local args = TarotM.query(cardId, "args") or {};
        local levelRange = args["level_range"];
        local min, max;

        -- 取得卷轴阶位的范围
        local range = string.explode(levelRange, "~");
        if #range > 1 then
            min = tonumber(range[1]);
            max = tonumber(range[2]);
        else
            min = tonumber(range[1]);
            max = min;
        end

        assert(max >= min);

        -- 抽取卷轴
        local differ = max - min;
        local rand = DungeonM.getRandSeed("tarot_hierophant");
        local rank = min + rand % (differ + 1);

        local spells = SpellM.getSpellByRank(rank);

        rand = DungeonM.getRandSeed("tarot_hierophant");
        local classId = spells[rand % #spells + 1];

        BonusM.doBonus({1, classId, 1, }, "tarot_bonus");
    end,
};
